package com.hxf.dao.appraisal.impl;

import org.springframework.stereotype.Repository;

import com.hxf.common.PublicUtil;
import com.hxf.dao.BaseDaoImpl;
import com.hxf.dao.appraisal.AppraisalDao;
import com.hxf.dto.AppraisalDto;
import com.hxf.dto.ReturnData;
import com.hxf.exception.DaoLevelException;

@SuppressWarnings("unchecked")
@Repository("appraisalDao")
public class AppraisalDaoImpl extends BaseDaoImpl implements AppraisalDao{

	@Override
	public ReturnData<AppraisalDto> findAppraisal(AppraisalDto appraisalDto, int targetPage, int pageSize) throws DaoLevelException { 
		String sql  = "";
		if (null != appraisalDto) {
			//类型
			if(PublicUtil.isNotNull(appraisalDto.getAppraisalType())){
				sql  += " and appraisalType = " + appraisalDto.getAppraisalType();
			}
			
			if (null != appraisalDto.getAppraisalTypeId()) {
				sql  += " and appraisalTypeId = " + appraisalDto.getAppraisalTypeId();
			}
			
			//餐厅ID
			if(null != appraisalDto.getRestaurantId()){
				sql += " and restaurantId = " + appraisalDto.getRestaurantId();
			}
			
		}
		
		return super.findBy("from AppraisalDto where 1 =1" +sql , targetPage, pageSize);
	} 
}
